package com.tpo;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.widget.TextView;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;


public class MapaActivity extends MapActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
    	
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.mapaview);
        
    	Bundle bundle=getIntent().getExtras();
        
        MapView mapView = (MapView) findViewById(R.id.mapauadeview);
        TextView data = (TextView) findViewById(R.id.lbl_text);
        
        data.setText(bundle.getString("data"));
        
        Geocoder geo= new Geocoder(this);
		List<Address> direccion;
		direccion = null;
		
		try {
			direccion = geo.getFromLocationName(bundle.getString("ciudad"), 4);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
		
		
        Iterator<Address> it=direccion.iterator();
        
        Address objetoDireccion;
        objetoDireccion = null;
        
		if(it.hasNext())
        {
        	objetoDireccion=(Address) it.next();
        	
        }

		
        int latitude = (int)(objetoDireccion.getLatitude() * 1000000); 
        int longitude = (int)(objetoDireccion.getLongitude() * 1000000); 
        
        GeoPoint point = new GeoPoint(latitude,longitude);
        mapView.getController().setZoom(10);
        mapView.getController().setCenter(point);
       
    }

    @Override
    protected boolean isRouteDisplayed() { return false; }

}
